import request from "@/utils/request";

// 登录验证
export const login = (data) => {
  return request({
    method: "POST",
    url: "/v1_0/authorizations",
    data,
  });
};

// 发送短信验证码
export const verifi = (mobile) => {
  return request({
    method: "GET",
    url: `/v1_0/sms/codes/${mobile}`,
  });
};

// 获取自己的用户信息
export const openUser = () => {
  return request({
    method: "GET",
    url: `/v1_0/user`,
  });
};

// 获取用户频道
export const getChannel = () => {
  return request({
    method: "GET",
    url: `/v1_0/user/channels`,
  });
};

// 关注用户
export const addFollow = (target) => {
  return request({
    method: "POST",
    url: `/v1_0/user/followings`,
    data: { target },
  });
};

// 取消关注用户
export const delFollow = (target) => {
  return request({
    method: "DELETE",
    url: `/v1_0/user/followings/${target}`,
  });
};

// 获取用户个人资料
export const getUserData = () => {
  return request({
    method: "GET",
    url: `/v1_0/user/profile`,
  });
};

// 修改用户个人资料
export const modUserData = (data) => {
  return request({
    method: "PATCH",
    url: `/v1_0/user/profile`,
    data,
  });
};

// 修改用户头像
export const modUserPhoto = (data) => {
  return request({
    method: "PATCH",
    url: `/v1_0/user/photo`,
    data,
  }); 
};
